package io.bluerain.g4_tools.utils;

import com.google.gson.Gson;

/**
 * Created by foredawn on 15-9-14.
 * JSON <-> Object 转换工具类
 */
public class JsonUtils {

    public static String toJson(Object object) {
        // 将对象编译成json
        Gson gson = new Gson();
        String result = gson.toJson(object);
        return result;
    }

    public static Object toObj(String json, Class<?> clazz) {
        Gson gson = new Gson();
        return gson.fromJson(json, clazz);
    }
}
